package com.pubinfo.passbook.common.model.shortMessage;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

@Data
@NoArgsConstructor
public class ShortMessageHeadParam {
  @ApiModelProperty("渠道编码(由统一平台提供)")
  /**
   * 必填
   */
  private String channel;
  
  @ApiModelProperty("渠道token")
  /**
   * 必填
   * 渠道token生成规则：
   * 渠道秘钥+ channel +年月日（20160101）做MD5（32位大写）加密。
   */
  private String channel_token;
  
  @ApiModelProperty("渠道的具体业务模块")
  /**
   * 必填
   * 中文字符，字数不要超过20
   */
  private String bis_module;
  
  @ApiModelProperty("渠道的具体业务模块详情")
  /**
   * 必填
   * 中文字符，字数不要超过20
   */
  private String bis_detail;
  
  @ApiModelProperty("服务版本(由统一平台提供）默认v1.0")
  /**
   * 必填
   * 中文字符，字数不要超过20
   */
  private String version;
  
  public Map<String, Object> toMap() throws IllegalAccessException {
    Map<String, Object> map = new HashMap<>();
    Class<?> clazz = this.getClass();
    for (Field field : clazz.getDeclaredFields()) {
      field.setAccessible(true);
      if (ObjectUtils.anyNotNull(field.get(this))) {
        map.put(field.getName(), field.get(this));
      }
    }
    return map;
  }
  
  public static void main(String[] args) throws IllegalAccessException {
    ShortMessageHeadParam shortMessageHeadParam = new ShortMessageHeadParam();
    shortMessageHeadParam.setBis_detail("BisDetail");
    shortMessageHeadParam.setBis_module("BisModule");
    shortMessageHeadParam.setChannel("Channel");
    shortMessageHeadParam.setVersion("Version");
    shortMessageHeadParam.setChannel_token("ChannelToken");
    System.out.println(shortMessageHeadParam.toMap());
  }
}
